let matrix = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
];
let res = new Array(matrix.length).fill(0).map((item) => {
  return new Array(matrix[0].length).fill(0);
});
for (let i = 0; i < matrix.length; i++) {
  for (let j = 0; j < matrix[i].length; j++) {
    res[j][matrix.length - 1 - i] = matrix[i][j];
  }
}
console.log(res);
